# -*-encoding:utf8-*-
from django.shortcuts import render, redirect
from django.http import JsonResponse
import service,json


# Create your views here.
def login(request):
    '''登陆展示页面'''
    frm = request.GET.get("frm", '/main/index')
    return render(request, 'passport/login.html', {'frm': frm})


def doLogin(request):
    '''
    执行登录
    :param request:
    :return:
    '''
    phone = request.POST.get('phone', '')
    password = request.POST.get('password', '')
    data = service.passport.login(phone, password)
    request.session['phone'] = phone

    return JsonResponse(data)


def logout(request):
    '''
    退出系统
    :param request:
    :return:
    '''
    # 销毁数据
    return redirect('/passport/login')
